const path = require("path");
const fs = require("fs");
const directoryPath = path.join(__dirname, "work"); // 替换为你的目录路径
let allItem = {};
//动态读取文件进行入口文件打包
fs.readdirSync(directoryPath)
  .filter(function (file) {
    return fs.statSync(path.join(directoryPath, file)).isDirectory();
  })
  .forEach(function (file) {
    console.log(file); // 这里打印出所有找到的目录名称
    allItem[file] = `./work/${file}/main.js`;
  });
module.exports = {
  entry: allItem,
  watch: process.env.NODE_ENV == "development" ? true : false,
  mode: process.env.NODE_ENV,
  output: {
    filename: "[name]/main.js",
    path: path.resolve(__dirname, "dist"),
  },
};
